<template>
  <div>
    <!-- 按钮 -->
    <div class="btns">
      <el-button type="primary" size="small" @click="toFormHandler"
        >新增</el-button
      >
    </div>
    <!-- 表格 -->
    <div class="tab_content">
      <el-table :data="application" style="width: 100%">
        <el-table-column prop="question" label="问题" width="180">
        </el-table-column>
        <el-table-column prop="question_time" label="提出问题时间" width="180">
        </el-table-column>
        <el-table-column prop="replay" label="回复"> </el-table-column>
        <el-table-column prop="replay_time" label="回复时间"> </el-table-column>
        <el-table-column prop="status" label="处理状态"> </el-table-column>

                <!-- 操作列 -->
        <el-table-column width="100" align="center" label="操作">
          <template slot-scope="scope">
            <el-button type="text" @click="editHandler(scope.row)">修改</el-button>
            <el-button type="text" @click="deleteHandler(scope.row)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>


<script>
import { del } from "@/utils/request";
import { get } from "@/utils/request";
export default {
  data() {
    return {
      application: [],
      visible: false,
    };
  },
  methods: {
        // 删除的处理函数
    deleteHandler(row){
      this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        let url = "http://120.77.41.127:8888/greenhouseMessagge/deleteById"
        del(url,{id:row.id}).then(resp =>{
          // 1. 提示
          this.$message({type:"success",message:resp.message});
          // 2. 刷新
          this.loadApplication();
        })
      })
    },
    // 修改的处理函数
    editHandler(row){
      this.$router.push({ 
        path:"/tjm/greenhouse_message_Form" ,
        query:row
      })
    },

    // 跳转到温室大棚录入页面
    toFormHandler() {
      // 跳转
      this.$router.push({ path: "/tjm/greenhouse_message_Form" });
    },
    loadApplication() {
      let url = "http://120.77.41.127:8888/greenhouseMessagge/query";
      get(url).then((resp) => {
        this.application = resp.data;
      });
    },
  },
  created() {
    this.loadApplication();
  },
};
</script>

<style lang="sass" scoped>
</style>